﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using BartonExtension;
using Model;

namespace Backend
{
    public partial class LocationPicker : DevExpress.XtraEditors.XtraForm
    {
        private List<Mall> _data { get; set; }
        public DialogResult result { get; set; }
        public Mall chosen;
        public LocationPicker()
        {
            InitializeComponent();
        }

        public LocationPicker(List<Mall> data)
        {
            _data = data;
            InitializeComponent();
            Init();
            
        }
        void Init()
        {
            _data.ForEach(x =>
                {
                    rdPicker.Properties.Items.Add(new DevExpress.XtraEditors.Controls.RadioGroupItem(x,x.name + "    -    " + x.street));
                });
            rdPicker.SelectedIndex = 0;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            int selected = rdPicker.SelectedIndex;
            chosen = _data[selected];
            result = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            result = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }
    }
}